package com.yulongtian.offers.day202209.day20220922;

/**
 * https://leetcode.cn/problems/shan-chu-lian-biao-de-jie-dian-lcof/
 *
 * @author YulongTian
 * @date 2022/9/22 - 16:26
 */
public class Test03 {
    public static void main(String[] args) {

    }

    public ListNode deleteNode(ListNode head, int val) {
        if(head==null){
            return head;
        }
        if(head.val==val){
            return head.next;
        }
        ListNode point=head;
        ListNode pre=head;

        while (point!=null){
            if(point.val==val){
                pre.next=point.next;
                point=pre;
            }

            pre=point;
            point=point.next;
        }

        return head;
    }

    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }


}
